package com.chixing.day14_map;



import java.util.*;
import java.util.stream.Collectors;

public class Foo {

        private String code;
        private String name;

   public Foo(String code ,String name){

   }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Foo)) return false;
        Foo foo = (Foo) o;
        return Objects.equals(getCode(), foo.getCode()) && Objects.equals(getName(), foo.getName());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getCode(), getName());
    }

    @Override
    public String toString() {
        return "Foo{" +
                "code='" + code + '\'' +
                ", name='" + name + '\'' +
                '}';
    }

    public static void main(String[] args) {
        Foo f1=  new Foo("测试1","test a") ;
        Foo f2= new Foo("测试2","test b")  ;
        Foo f3= new Foo("测试1","test c");
        Foo f4= new Foo("测试3","test d");
        Foo f5= new Foo("测试3","test e") ;
        Foo f6= new Foo("测试4","test f");
        List<Foo> list =  new ArrayList<>();
        list.add(f1);
        list.add(f2);
        list.add(f3);
        list.add(f4);
        list.add(f5);
        list.add(f6);

        Map<String,List<Foo>> fooMap = new HashMap<>();
        for (Foo foo:list){
           String code = foo.getCode();
           if (fooMap.containsKey(code)){
               List<Foo> fooList = fooMap.get(code);
           }else {
               List<Foo> fooList = new ArrayList<>();
               fooList.add(foo);
               fooMap.put(code,fooList);
           }

       }


    }
    public class Test {
        float use(float a, float b) {return 0.0f;
        }
        float use( float d) {return 0.0f;  }
    }
}
